package dp.dayOne;

import java.util.ArrayList;
import java.util.List;

public class QuestionFour {
    public int maxProfit(int[] prices) {
        int len = prices.length;
        List<Integer> list = new ArrayList<>();
        int result = -1;
        int minTemp = 0;
        for (int i = 0; i < len-2; i++) {
            minTemp = prices[i];
            int temp = -1;
            for (int j = i+1; j < len-1; j++) {
                if (prices[j] < temp){
                    temp = prices[j];
                }
            }
            if (result <temp - prices[i]){
                result = temp - prices[i];
            }
        }
        return result;
    }
}
